﻿using System;
using AgileBoard.Domain;

namespace AgileBoard.Dtos.Mappers
{
    public class ActualsDTOMapper : BaseDTOMapper
    {
        public static ActualsDTO MapToDTO(Actual model)
        {
            var dto = new ActualsDTO();

            dto.ActualsID = model.ActualID;
            dto.Remain = model.Remain;
            dto.TaskID = model.TaskID;
            dto.LabelID = model.Label == null ? "" : model.Label.LabelID.ToString();
            dto.Label = model.Label == null ? "" : model.Label.Date;
            dto.CreateTime = model.CreateTime;
            dto.Creator = model.Creator;

            return dto;
        }

        public static Actual MapFromDTO(ActualsDTO dto)
        {
            var Actual = new Actual();
            Actual.ActualID = dto.ActualsID;
            Actual.Remain = dto.Remain;
            Actual.TaskID = dto.TaskID;
            Actual.Label = (dto.LabelID == null || dto.LabelID == "")
                               ? null
                               : ManagerFactory.LabelManager.Get(new Guid(dto.LabelID));
            Actual.CreateTime = dto.CreateTime;
            Actual.Creator = dto.Creator;
            return Actual;
        }
    }
}